<!DOCTYPE html>
<html lang="en">
<head>
    <title>短信项目修改</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" charset="utf-8">
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/util.js"></script>
    <script>
        layui.use(['layer', 'form', 'jquery'], function () {
            var layer = layui.layer;
            var form = layui.form;
            var $ = layui.$;
            var mgrId=getUrlParam("id");

            $(document).ready(function () {
                var param={
                    mgrId:mgrId
                };
                var url="/busi/findByMgrId";
                $.ajax({
                    type: 'post',
                    data: param,
                    url: url,
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        var data=json.data;
                        layer.close(loading);
                        $("#cityId").val(data.cityId);
                        $("#name").val(data.name);
                        form.render();
                    },
                    error: function (data) {
                        layer.msg("系统异常,请联系管理员");
                    }
                });
            });


            $('#modify').on('click', function () {
                var name = $("#name").val();
                var cityId=$("#cityId").val();
                var param = {
                    id:mgrId,
                    name: name,
                    cityId: cityId
                };
                var url = "/busi/modify";
                $.ajax({
                    type: 'post',
                    data: param,
                    url: url,
                    beforeSend: function () {
                        if (isNull(name)) {
                            layer.msg("项目名称不能为空");
                            return false;
                        }
                        if(isNull(cityId)){
                            layer.msg("必须选择一个城市");
                            return false;
                        }
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        if (json.code == 0) {
                            layer.msg('修改成功');
                        }else {
                            layer.msg(json.msg);
                        }
                    },
                    complete: function () {

                    },
                    error: function (data) {
layer.msg("系统异常,请联系管理员");
                    }
                });
            });
        });
    </script>
</head>

<body>
<div class="scroll-box">
    <div class="content-box" align="center">
        <div class="form-select-box">
            <div class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <div class="layui-inline layui-inline-center">
                        <label class="layui-form-label">省份</label>
                        <div class="layui-input-block">
                            <input type="text" name="province" lay-verify="required" value="江苏"
                                   autocomplete="off" class="layui-input" disabled>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline layui-inline-center">
                        <label class="layui-form-label">地市</label>
                        <div class="layui-input-block">
                            <select name="cityId" lay-filter="cityId" id="cityId">
                                <option value="">请选择</option>
                                <option value="11">苏州</option>
                                <option value="12">淮安</option>
                                <option value="13">宿迁</option>
                                <option value="14">南京</option>
                                <option value="15">连云港</option>
                                <option value="16">徐州</option>
                                <option value="17">常州</option>
                                <option value="18">镇江</option>
                                <option value="19">无锡</option>
                                <option value="20">南通</option>
                                <option value="21">泰州</option>
                                <option value="22">盐城</option>
                                <option value="23">扬州</option>
                                <option value="25">省级</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline layui-inline-center">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" required lay-verify="required" placeholder="请输入项目名称"
                                   autocomplete="off" class="layui-input" id="name">
                        </div>
                    </div>
                </div>
                <div class="layui-block" pane="" >
                    <button class="layui-btn layui-btn-normal" id="modify">修&nbsp;改</button>
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>